package 代码记录.校招笔试真题.笔试真题_2023.神策数据;

import java.util.Scanner;

/**
 * @author zx
 * @create 2023-03-05 16:00
 * 金融指标计算
 * 0.65
 */
public class Test3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        int[] temp = new int[n];
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                if(i != j){
                    temp[i] = Math.max(temp[i],arr[i] + arr[j] - (Math.max(i,j) - Math.min(i,j)));
                }else{
                    continue;
                }
            }
        }
        int res = 0;
        for(int i = 0;i < n;i++){
            res = Math.max(res,temp[i]);
        }
        System.out.println(res);
    }
}
